﻿package view.task
{
    import com.sh.game.util.*;
    import flash.utils.*;
    import morn.core.components.*;

    public class ActiveItemUI extends View
    {
        public var label:Label;
        public var btn:Button;
        public var data:Object;
        public var endtime:int;
        public var starttime:int;
        private var _lodtime:int = 0;
        public var hasStart:Boolean = false;
        protected var uiXML:XML;
        private var _timeID:uint = 0;

        public function ActiveItemUI()
        {
            this.uiXML = <View>
n	t	t	t  <Label text=""[活动]"" x=""2"" y=""0"" width=""196"" height=""20"" isHtml=""true"" var=""label"" stroke=""0x0"" color=""0xffffff""/>
n	t	t	t  <Button skin=""png.common.btn_trans"" x=""200"" y=""1"" var=""btn""/>
n	t	t	t</View>")("<View>
			  <Label text="[活动]" x="2" y="0" width="196" height="20" isHtml="true" var="label" stroke="0x0" color="0xffffff"/>
			  <Button skin="png.common.btn_trans" x="200" y="1" var="btn"/>
			</View>;
            return;
        }// end function

        public function get lodtime() : int
        {
            return this._lodtime;
        }// end function

        public function set lodtime(param1:int) : void
        {
            this._lodtime = param1;
            if (this._timeID > 0)
            {
                clearInterval(this._timeID);
                this._timeID = 0;
            }
            if (this._lodtime > 0)
            {
                this._timeID = setInterval(this.settxt, 1000);
            }
            return;
        }// end function

        private function settxt() : void
        {
            var _loc_1:String = this;
            var _loc_2:* = this._lodtime - 1;
            _loc_1._lodtime = _loc_2;
            if (this._lodtime <= 0)
            {
                if (this._timeID > 0)
                {
                    clearInterval(this._timeID);
                    this._timeID = 0;
                }
                return;
            }
            if (this.data)
            {
                this.label.text = MColor.getHMTL("[" + this.data.name + "] ", 70) + MColor.getHMTL("倒计时(" + TimeDataFormatUtil.getLeftTime2(this._lodtime) + ")", 56);
            }
            return;
        }// end function

        override protected function createChildren() : void
        {
            createView(this.uiXML);
            return;
        }// end function

    }
}
